package io.github.lee.app.unsplash.global

import android.app.Application
import dagger.hilt.android.HiltAndroidApp
import io.github.lee.app.unsplash.global.di.http.HttpModule
import io.github.lee.app.unsplash.global.di.http.interceptor.PublicHeaderInterceptor
import io.github.lee.app.unsplash.global.di.http.interceptor.UnsplashResponseInterceptor
import okhttp3.Interceptor
import okhttp3.logging.HttpLoggingInterceptor

@HiltAndroidApp
class UnsplashApplication : Application() {
    override fun onCreate() {
        super.onCreate()

        val list = mutableListOf<Interceptor>()
            .also {
                it.add(PublicHeaderInterceptor())
                it.add(UnsplashResponseInterceptor())
                it.add(HttpLoggingInterceptor().also { interceptor ->
                    interceptor.setLevel(HttpLoggingInterceptor.Level.BODY)
                }
                )
            }
        HttpModule.init("https://api.unsplash.com", list)
    }
}